/*!
 * Copyright (c) 2012
 * Automation and Robotics Lab (LARA) at University of Brasilia (UnB)
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     - Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     - Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     - Neither the name of the Automation and Robotics Lab (LARA) nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License LGPL as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License LGPL for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License LGPL along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 *****************************************************************
 *
 *   ROS stack name: schunk
 *   ROS package name: schunk_high
 *
 *   Authors: André A. Geraldes, email: andregeraldes@lara.unb.br
 *            Murilo M. Marinho, email: murilomarinho@lara.unb.br
 *
 *****************************************************************/

#ifndef ROSPKG_SCHUNK_HIGH_JOINT_VELOCITY_CONTROLLER_H_
#define ROSPKG_SCHUNK_HIGH_JOINT_VELOCITY_CONTROLLER_H_

/******************************************************************************
                                   INCLUDES
 *****************************************************************************/

// Schunk_high
#include <schunk_high/cartesian_controller.h>

class JointVelocityController : public CartesianController
{
    private:

        // Subscribers
        ros::Subscriber subscriber_joint_references_;

        // Service Servers
        ros::ServiceServer service_server_init_control_;
        ros::ServiceServer service_server_enable_control_;
        ros::ServiceServer service_server_disable_control_;

        // Messages
        schunk_msgs::JointVelocities subscriber_joint_references_message_;

        // Subscribed Topic Callbacks
        void ReferencesCallback(const schunk_msgs::JointVelocities::ConstPtr& msg);

        // Services Server Callbacks
        bool InitCallback(schunk_high::Init::Request& req, schunk_high::Init::Response& resp);
        bool EnableCallback(schunk_high::Enable::Request& req, schunk_high::Enable::Response& resp);
        bool DisableCallback(schunk_high::Disable::Request& req, schunk_high::Disable::Response& resp);

    public:

        // Constructor
        JointVelocityController();

        // Destructor
        ~JointVelocityController();

        // Parameter Loading Functions
        bool GetVelocityParameters();

        // Declare the control function just fulfill the requirement of the parent class
        void Control();
};

#endif  // ROSPKG_SCHUNK_HIGH_JOINT_VELOCITY_CONTROLLER_H_
